<template>
	<view class="">
		<moreList :title="title" :typeid="typeid" :infoData='infoData' @eveFun="handlePageSet"></moreList>
	</view>
</template>

<script>
	import moreList from '@/components/morelist/index.vue'
	export default {
		components: {
			moreList
		},
		onLoad(item) {
			
			this.typeid=item.typeid

		},
		mounted() {
			if (this.typeid == 1) {
				this.title = '平台公告'
				this.getNoticelist()
			}
			if (this.typeid == 2) {
				this.getNewslist()
				this.title = '集团要闻'
			}
		},
		data() {
			return {
				title: '',
				typeid:'',
				infoData: [
					// contentTitle:'公告公告公告公告',
					// content:'公告公告公告公告公告公告'
				],
				pageSet: {
					pages: 1,
					current: 1
				}
			}
		},
		provide() {
			return {
				pageSet: this.pageSet,
			};
		},
		methods: {
			handlePageSet(data){
				this.pageSet.current=data
				this.getNewslist()
			},
			getNoticelist() {
				const param = {
					current: 1,
					size: 10
				}
				this.$request.get('/CatNotise/notise/all', param).then(res => {

					if (res.code == 200) {

						const notise = res.data.Notise.records;
						this.infoData = notise.map(item => ({
							contentTitle: item.noTitle,
							detid:item.noTitle
						}))
						this.pageSet.pages = res.data.Notise.pages;
						this.pageSet.total = res.data.Notise.total
					}

				})
			},
			getNewslist() {
				const param = {
					current: this.pageSet.current,
					size: 5
				}
				this.$request.get('/CatNews/list', param).then(res => {
					console.log(res);
					if (res.code == 200) {
						const news = res.data.news.records;
						this.infoData = news.map(item => ({
							contentTitle: item.ntitle,
							detid:item.nid
						}))
						this.pageSet.pages = res.data.news.pages;
						this.pageSet.total = res.data.news.current
					}

				})
			}
		}
	}
</script>

<style>
</style>